/**
 * storage二次封装
 * @author: Hongxu
 */
import config from '../config/index.js'
//本地存储类
export default {
    //存储
    setItem(key, val) {
        const storage = this.getStorage();
        storage[key] = val;
        window.localStorage.setItem(config.namespace, JSON.stringify(storage))
    },
    getItem(key) {
        return this.getStorage()[key];
    },
    getStorage(key) {
        return JSON.parse(window.localStorage.getItem(config.namespace) || "{}")
    },
    clearItem(key) {
        const storage = this.getStorage;
        delete storage[key];
        window.localStorage.setItem(config.namespace, JSON.stringify(storage))
    },
    clearAll() {
        window.localStorage.clear();
    },
}